<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('服务模块功能配置列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <input type="hidden" name="moduleId" id="moduleId" th:value="${moduleId}"/>
                    <li>
                        <label>功能名称：</label>
                        <input type="text" name="functionName"/>
                    </li>
                    <li>
                        <label>功能类型：</label>
                        <select name="functionType" class="selectpicker"
                                th:with="type=${@dict.getType('ecard_function_type')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </li>
                    <li>
                        <label>功能状态：</label>
                        <select name="functionSts" class="selectpicker"
                                th:with="type=${@dict.getType('sys_sts')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                class="fa fa-search"></i>&nbsp;搜索</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                class="fa fa-refresh"></i>&nbsp;重置</a>
                    </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="add()"
               shiro:hasPermission="ecard:config:serveModuleFunction:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="ecard:config:serveModuleFunction:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="ecard:config:serveModuleFunction:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="ecard:config:serveModuleFunction:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('ecard:config:serveModuleFunction:edit')}]];
    var removeFlag = [[${@permission.hasPermi('ecard:config:serveModuleFunction:remove')}]];
    var functionTypeDatas = [[${@dict.getType('ecard_function_type')}]];
    var functionStsDatas = [[${@dict.getType('sys_sts')}]];
    var prefix = ctx + "ecard/config/serveModuleFunction";

    $(function () {
        var options = {
            url: prefix + "/list",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "服务模块功能配置",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'moduleId',
                    title: '模块ID'
                },
                {
                    field: 'functionName',
                    title: '功能名称'
                },
                {
                    field: 'functionType',
                    title: '功能类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(functionTypeDatas, value);
                    }
                },
                {
                    field: 'functionIcon',
                    title: '功能图标',
                    formatter: function (value, row, index) {
                        return $.table.imageView(row.functionIcon, 300, 300);
                    }
                },
                {
                    field: 'skipUrl',
                    title: '跳转链接'
                },
                {
                    field: 'orderNumber',
                    title: '显示顺序'
                },
                {
                    field: 'functionSts',
                    title: '功能状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(functionStsDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        if (row.functionType == 1) {
                            actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="newsList(\'' + row.id + '\')" shiro:hasPermission="ecard:config:serveModuleNews:view"><i class="fa fa-list-ul"></i>新闻配置</a> ');
                        }
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function add() {
        var moduleId = $("#moduleId").val();
        var createUrl = prefix + "/add/" + moduleId;
        $.modal.open("新增功能模块", createUrl);
    }

    function newsList(id) {
        var url = ctx + "ecard/config/serveModuleNews/" + id;
        $.modal.openTab("内部新闻配置", url);
    }
</script>
</body>
</html>